package com.yun.algorithmproblem.leetcode;

public class Leetcode14 {
    public String longestCommonPrefix(String[] strs) {
        char[] first = strs[0].toCharArray();
        for (int i = 0; i < first.length; i++) {
            char ch = first[i];
            for (int j = 1; j < strs.length; j++) {
                if(strs[j].length()==i || ch != strs[j].charAt(i)){//情况1,2
                    return new String(first, 0, i);
                }
            }
        }
        return strs[0];
    }
}
